package com.song.alibaba.user.controller;

import com.song.alibaba.user.domain.User;
import com.song.alibaba.user.feign.BookFeignService;
import com.song.alibaba.user.service.UserService;
import entity.R;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {

    @Resource
    private UserService userService;

    @Resource
    private BookFeignService bookFeignService;//只有接口没有实现类：与Mybatis 相同：反射机制动态代理实现

    @GetMapping("/users")
    public R<List<User>> findAll(){
        return new R(200,"",this.userService.list());
    }


    @GetMapping("/books")
    public R findBooks(){
        return this.bookFeignService.books();
    }
}
